#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
ll a[N];
vector<ll> get_p(ll n) {
  vector<ll> ans;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i) continue;
    ans.push_back(i);
    while (n % i == 0) n /= i;
  }
  if (n > 1) ans.push_back(n);
  return ans;
}
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 1, n) cin >> a[i];
  vector<ll> primes = get_p(a[1]);
  rep(i, 1, n) {
    ll x = gcd(a[1], a[i]);
    if (x == 1)
      cout << -1 << ' ';
    else {
      for (ll p : primes) {
        if (x % p == 0) {
          cout << x / p << ' ';
          break;
        }
      }
    }
  }
  return 0;
}